package com.gupao.coupon.portal.couponportal.controller;

import org.apache.dubbo.config.annotation.DubboReference;
import org.gupao.normal.example.ICouponService;
import org.gupao.normal.example.dto.CouponDto;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.ValidationException;

/**
 * @Author: Mic
 * @公众号： 跟着Mic学架构
 * @官网： https://ke.gupaoedu.cn
 * @Org: 咕泡教育
 **/
@RestController
public class CouponController {

    @DubboReference(registry = "nacos-registry",version = "2.0",cluster = "failover",retries = 4)
    private ICouponService couponService;

    @GetMapping("/save")
    public String saveCoupon(){
        CouponDto couponDto=new CouponDto();
        try {
            return couponService.saveCoupons(couponDto);
        }catch (ValidationException e){
            e.printStackTrace();
            return e.getLocalizedMessage();
        }
    }
}
